package com.itheima.controller;


import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.itheima.pojo.Code;
import com.itheima.pojo.Result;
import com.itheima.pojo.ShoppingCart;
import com.itheima.service.impl.ShoppingCartServiceImpl;
import lombok.extern.log4j.Log4j2;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Log4j2
@RestController
@RequestMapping("/shoppingCart")
public class ShoppingCartController {

    @Autowired
    private ShoppingCartServiceImpl shoppingCartService;
    @Autowired
    private RedisTemplate redisTemplate;


    @PostMapping("/add")
    public Result add(@RequestBody ShoppingCart shoppingCart) {
        return shoppingCartService.add(shoppingCart);
    }


    @DeleteMapping("/clean")
    public Result delete(){
        return shoppingCartService.delete();
    }

    @PostMapping("/sub")

    public Result deleteById(@RequestBody ShoppingCart shoppingCart){
        return shoppingCartService.deleteById(shoppingCart);
    }

    @GetMapping("/list")
    public Result list(){

        // List<ShoppingCart> list = shoppingCartService.list();
        return shoppingCartService.listAll();

    }

}
